Scripting Tutorial: Popups



Popups are the little boxes that 'pop up' when you right click on an mIRC window. They also serve as short-cuts to mIRC functions like Aliases. The difference between Aliases and Popups are: for Aliases you need to type the alias name into the window and for Popups, you right click, look at the short-cut customized name for a task you want mIRC to perform and click it to perform the task. One is text based and the other is click based.

Look at the picture shown at the left, that's how a Popup looks like. You get that one when you right click in the nickname list (the column at the right corner of the channel window, where you see the nicknames). Try clicking there. Depending on whether you are using a script or not you should see something similar to the picture shown here; it's the default mIRC nickname list Popup.

Once again, to write useful and interesting Popups you need to know mIRC commands and should have at least a fair knowledge about how Aliases, Variables and Identifiers work. Read them up from the mIRC Help File. Better get the whole file printed out and take it along with you and read it whenever and wherever you can find a place to. It's not just about reading, you need to try out things and see for yourself how they come out too. The mantra for becoming a good scripter is - "Keep writing scripts"

Now let's start with creating your first Popup. First take a look at the Popup files for the Popups in mIRC. Press ALT+P (this takes you directly to the Editor in Popups mode). See the codes? Most probably the Popups file for the Status window will be put in the Edit mode. Right click in the Status window and analyze the codes and the corresponding Popup. If you want to see the Popup file for NickList, click on View and choose Nick List. Now take a look at the codes and compare with what you see in the Nick List Popup when you right click. Making sense?

Let's get going with what we were upto. First you have to decide which window you want to write the Popup for. If it's for the Channel window, click on View and select Channel, similarly, the same for other windows. Now copy and paste the following codes into the Popup editbox in the Editor. We are going to make a Popup for the channel window. Make sure you have chosen Channel from the View Menu.
- 
My First Popup: / 
- 
Hello: say Hello everybody! 
Bye: say Good bye everybody! 
- 
Greetings 
.B-Day: say Happy Birthday to $snicks $+ ! 
.Christmas: say A merry Christmas to each and everyone of u! 
.New Year: say New Year Wishes to all! 
Action
.Kick: { 
  me kicks $snicks in the ass *HUH!* 
  say you liked it $snicks ? 
} 
.Bonk: { 
  me bonks $snicks $+ 's head with a viking club*BONK!* 
  me wonders if $snicks is still alive 
  say $snicks are you alive? 
} 
.Flirt: { 
  me flirts with $snicks 
  say $snicks I love you 
  .timer 1 5 say $snicks $+ , it's been 5 secs that I started flirting with you 
  .timer 1 6 say $snicks don't you think I type quite fast? 
  .timer 1 7 say Look at the way I'm typin so fast... YOooHOoo! 
} 
- 
Quit: quit 0wn3d by a Popup! 
Close mIRC: exit
The above code will create the Popup show below in the pic. Using the above code as an example, I will cover the topic on Popups for beginners. Let me explain you the code. The - is to create a line separator between the menus. I used it in the first line to separate the new Popup menu from the already existing Channel Modes menu of the channel Popup. The menu 'My First Popup' is a functionless menu, I used it to give a name to the Popup we just created.

Popups menu definitions follow this pattern Menu name: mIRC-command. For eg: Hello: /say Hello everybody will perform the command /say Hello everybody when you click on Hello in the Popup menu. Hello is the menu name and /say Hello everybody is the command executed by mIRC. Similarly Bye is the menu name and /say Good bye everybody! is the command.

In the next menu we have Greetings as the main menu and B-Day, Christmas and New Year as submenus. Submenus are created by putting a . (dot) infront of the submenu name following the menu name. And if you want to create submenus under a submenu, you need to put .. (two dots) in front of the sub-submenu name following the submenu name.

Now we will change the submenu for Bonk under the menu Action and put submenus under it (Bonk). Change the code for Bonk in the last example code to the following.

.Bonk
..Gaul: me bonks $snicks with a Gaulish club *4BONK!*
..Viking: me bonks $snicks with a Viking club *4BONK!*
..American: me bonks $snicks with an American baseball bat*4BONK!*


The modification in the code for Bonk will result in a Popup which looks like the one in the pic at the left. Here we saw how submenus were added to a submenu of a menu. If you'd like to add submenus to Gaul, Viking and American you will need to put ... (three dots) in front of the submenu name under them.

In the Greetings menu code you must have noticed the $snicks, it is another identifier; used to denote the selected Nick from the Nick List - another instance which proves you need to know about identifiers and other aspects of mIRC scripting. And the $+ is yet another identifier that's used to join two pieces of the parts of a code, which are otherwise illegal. $snicks! will prevent ur code from performing the task u want to, so we use $snicks $+ !; which adds ! immediately after the selected nick. Note how $+ is used in the other parts of the code.

In the action menu, we have 3 submenus. The first one is kick. Let's assume your nick is Johnny-Bravo and say, you selected a nick called The-Joker and clicked on Kick. You get...
* Johnny-Bravo kicks The-Joker in the ass *HUH!*
<Johnny-Bravo> you liked it The-Joker ?

That Popup performed two actions. First it 'kicked' the selected nick and then asked him something. To include more than one command in the Popup (also in remotes), we enclose the commands within { } (curley brackets). Look at the Kick Popup code...

.Kick: {
me kicks $snicks in the ass *HUH!*
say you liked it $snicks ?
}


Notice how the command lines are enclose by an opening curly bracket and then closed by another. You can observe the same in the other submenu - Flirt. It contains 5 commands, all of them enclosed within { }. In the the submenu Flirt you can see .timer 1 5. It's an mIRC command which starts a timer and executes the mIRC command(s) according to the specification. timer 1 5 will execute the command following it, once after 5 secs (1 5). I included this example to stress the importance of knowing the IRC commands in writing useful and interesting scripts. Try removing the . (dot) before the timer command and see what happens.

You can also create Popups from a Remote file; it's discussed in the chapter on Remotes.

If you already know the mIRC Commands and Variables, you can very well write many useful and impressive scripts right at this stage too. I won't be including a detail chapter on Commands and Variables. You will have to learn them yourself. They are already in the Help File.

Before we move on to Remote, it would be best if we learnt about Identifiers, common mIRC Commands, Variables, Operators and program structure and flow. Let's start with Identifiers.


Back | Table of Contents | Identifiers



Copyright © 2002-2004 SpyderWares.
Feel free to distribute this tutorial in part or whole, just make sure the credits stay intact.

http://spyderwares.com